<?php


namespace app\common\model;


use think\Model;

class PartyMemberFineStyleModel extends Model
{
    protected $name = 'party_member_fine_style';




    protected function getImageAttr($value)
    {
        return wdsxh_full_url($value,false);
    }

    /**
     * 获取分页列表
     * @param int $page
     * @param int $limit 数据条数
     * @return array
     */
    public function getPageList($page = 1, $limit = 5): array
    {
        try {
            $where = [
                'status' => '1'
            ];
            $field = ['id','title','image'];
            $order = [
                'weigh' => 'asc',
            ];
            $list = $this
                ->where($where)
                ->field($field)
                ->order($order)
                ->paginate($limit, false, ['page' => $page]);
            return [
                'code' => 200,
                'msg' => '请求成功',
                'data' => $list
            ];
        }catch (\Exception $e) {
            return [
                'code' => $e->getCode(),
                'msg' => $e->getMessage(),
                'data' => []
            ];
        }
    }

    /**
     * 详情
     * @param int $id
     * @return array
     */
    public function getDetail($id): array
    {
        try {
            $data = $this->get($id);
            return [
                'code' => 200,
                'msg' => '请求成功',
                'data' => $data
            ];
        }catch (\Exception $e) {
            return [
                'code' => $e->getCode(),
                'msg' => $e->getMessage(),
                'data' => []
            ];
        }
    }

}